## Project Euler 27 solution.
## Simple, pendantic, fast enough.
print("Producin' me some primes.")
primes={2,3}
for n in range(5, 10000, 2):
    is_prime = True
    for prime in primes:
        if n % prime == 0:
            is_prime=False
            break
    if is_prime:
        primes.add(n)

def euler_like_quadratic(n,a,b):
    return n**2 + a*n + b

print("Produced me some primes.")

max,maxa,maxb=0,0,0
for a in range(-999, 1000):
    for b in range(-999, 1000):
        n=0
        test_prime = euler_like_quadratic(n,a,b)
        while test_prime in primes:
            n+=1
            test_prime = euler_like_quadratic(n,a,b)
        if n > max:
            max,maxa,maxb=n,a,b
print(maxa*maxb)